package com.demo.controller;

import com.demo.function.rocketmq.producer.Producer;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * RocketMQ 控制层
 * @author K
 */
@RestController
public class RocketMqController {

    @Resource
    private Producer producer;

    @ApiOperation("同步发送消息")
    @GetMapping("/rocketmq/sendMsg")
    public String sendMsg() {
        producer.sendMsg();
        return "sendMsg 发送成功";
    }

    @ApiOperation("同步发送消息，并设置超时时间")
    @GetMapping("/rocketmq/syncSend")
    public String syncSend() {
        producer.syncSend();
        return "syncSend 发送成功";
    }

    @GetMapping("/rocketmq/convertAndSend")
    public String convertAndSend() {
        producer.convertAndSend();
        return "convertAndSend 发送成功";
    }

    @GetMapping("/rocketmq/sendAndReceive")
    public String sendAndReceive() {
        producer.sendAndReceive();
        return "sendAndReceive 发送成功";
    }

    @GetMapping("/rocketmq/sendDelay")
    public String sendDelay() {
        producer.sendDelay();
        return "sendDelay 发送成功";
    }

    @ApiOperation("OneWay方式发送，不需等待服务器的响应")
    @GetMapping("/rocketmq/sendOneWay")
    public String sendOneWay() {
        producer.sendOneWay();
        return "sendOneWay 发送成功";
    }

    @GetMapping("/rocketmq/syncSendOrderly")
    public String syncSendOrderly() {
        producer.syncSendOrderly();
        return "syncSendOrderly 发送成功";
    }

    @GetMapping("/rocketmq/asyncSend")
    public String asyncSend() {
        producer.asyncSend();
        return "asyncSend 发送成功";
    }
}
